<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/2/9 0009
 * Time: 14:53
 */
/** @var string $sid */
/** @var string $cmd2 */

$player =  $game->player_get_uinfo();
$guaiwu = $game->gw_get_info($arr_data->gid);


if (!$guaiwu){
    $html = $game->create_pve_not($变量_系统);
    exit($html);
}

switch ($arr_data->cmd2){
    case 'intopve':

        if($player->ulv <= 10){
            $game->player_re_hp( );
            $player =  $game->player_get_uinfo( );
        }

        if ( !($player->ulv >= 10 && $player->uhp <=0) ){
            $game->gw_set_sid( $arr_data->gid );
            $html = $game->create_pve_info( $player , $guaiwu , 0 , 0 , 0 , 0 , "普通攻击" ,$变量_系统);
        }else{
            $html = $game->create_pve_cannot($变量_系统);
        }

        echo $html;

        break;
    case 'ptgj':
        $output = 0;

        $phurt = $game->pve_get_phurt($player , $guaiwu);
        $ghurt = $game->pve_get_ghurt($player , $guaiwu);


        $ran = mt_rand(1,100);
        if ($player->ubj >= $ran){
            $ghurt = $ghurt * 2 ;
            $baoji_player = true;
        }else{
            $baoji_player = false;
        }

        $xx_player = ceil($ghurt * ($player->uxx/100) );
        if ( $phurt < $xx_player ){
            $xx_player = $phurt - 1;

            if ( $xx_player < 0 ){
                $xx_player = 0;
            }
        }


        $game->gw_change_hp($ghurt , 2 , $arr_data->gid);
        $game->player_change_uhp($phurt - $xx_player , 2 );
        $player =  $game->player_get_uinfo();
        $guaiwu = $game->gw_get_info($arr_data->gid);
        $html = $game->create_pve_info( $player , $guaiwu , $phurt , $ghurt , $baoji_player , $xx_player , "使用普通攻击" ,$变量_系统);

        if ($player->uhp <= 0 ){//先判断玩家是否死亡
            $html = $game->create_pve_lose($guaiwu,$变量_系统);
        }elseif($guaiwu->ghp <=0){//玩家没死再次判断怪物是否死亡
            $html = $game->create_pve_win($guaiwu,$变量_系统);
        }

        echo $html;
        break;
    case "useyp":
        $ret = $game->yp_use( $arr_data->ypid , 1);
        $player = $game->player_get_uinfo();
        $html = $game->create_pve_info( $player , $guaiwu , 0 , 0 , 0 , 0 , "使用药品" , $变量_系统);
        echo $html;
        break;
    case "usejn":

        $ret_jn_sub = $game->jn_sub($arr_data->jnid , 1);
        $tishi = "技能数量不足";
        if ($ret_jn_sub){
            $jn_sys = $game->jn_get($arr_data->jnid );

            $player->ugj += $jn_sys->jngj;
            $player->ufy += $jn_sys->jnfy;
            $player->ubj += $jn_sys->jnbj;
            $player->uxx += $jn_sys->jnxx;
            $tishi = "使用技能{$jn_sys->jnname}";
        }


        $phurt = $game->pve_get_phurt($player , $guaiwu);
        $ghurt = $game->pve_get_ghurt($player , $guaiwu);

        $ran = mt_rand(1,100);
        if ($player->ubj >= $ran){
            $ghurt = $ghurt * 2 ;
            $baoji_player = true;
        }else{
            $baoji_player = false;
        }

        $xx_player = ceil($ghurt * ($player->uxx/100) );
        if ( $phurt < $xx_player ){
            $xx_player = $phurt - 1;

            if ( $xx_player < 0 ){
                $xx_player = 0;
            }
        }

        $game->gw_change_hp($ghurt , 2 , $arr_data->gid);
        $game->player_change_uhp($phurt - $xx_player , 2 );
        $player =  $game->player_get_uinfo();
        $guaiwu = $game->gw_get_info($arr_data->gid);
        $html = $game->create_pve_info( $player , $guaiwu , $phurt , $ghurt , $baoji_player , $xx_player , $tishi ,$变量_系统);

        if ($player->uhp <= 0 ){//先判断玩家是否死亡
            $html = $game->create_pve_lose($guaiwu,$变量_系统);
        }elseif($guaiwu->ghp <=0){//玩家没死再次判断怪物是否死亡
            $html = $game->create_pve_win($guaiwu,$变量_系统);
        }

        echo $html;
        break;

}





